package com.xlk.restful.client;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.xlk.restful.domain.User;
import com.xlk.restful.service.RESTSample;

public class RESTServiceClient {
	public static void main(String[] args) throws Throwable {
		// 手动创建
		//RESTSample sample = JAXRSClientFactory.create("http://localhost:8000/CXFWebService/rest", RESTSample.class);
		 
		// 从Spring Ioc容器中拿webClient对象
		ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-client.xml");
		RESTSample sample = ctx.getBean("restSampleBean", RESTSample.class);
		 
		System.out.println(sample);
		 
		System.out.println(sample.doGet());
		//System.out.println(sample.doRequest("haha", null, null));
		System.out.println(sample.getBean(22));
		System.out.println(sample.getList());
		System.out.println(sample.getMap().getMap());
		User user = new User();
		user.setId(21432134);
		user.setAddress("hoojo#gz");
		user.setEmail("hoojo_@126.com");
		user.setName("hoojo");
		System.out.println(sample.postData(user));
		System.out.println(sample.putData(111, user));
		sample.deleteData(2);
	}
}
